package com.jzo2o.customer.controller.consumer;

import com.jzo2o.api.customer.dto.request.EvaluationSubmitReqDTO;
import com.jzo2o.api.customer.dto.response.AddressBookResDTO;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.domain.AddressBook;
import com.jzo2o.customer.model.dto.request.*;
import com.jzo2o.customer.model.dto.response.AllEvaluationSystemInfoResDTO;
import com.jzo2o.customer.model.dto.response.BooleanResDTO;
import com.jzo2o.customer.model.dto.response.EvaluationAndOrdersResDTO;
import com.jzo2o.customer.model.dto.response.EvaluationResDTO;
import com.jzo2o.customer.service.EvaluationService;
import com.jzo2o.customer.service.IAddressBookService;
import com.jzo2o.mvc.utils.UserContext;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 评价相关接口
 *
 * @author itcast
 * @create 2023/9/11 16:14
 **/
@RestController("consumerAddressBookController")
@RequestMapping("/consumer/address-book")
@Api(tags = "用户端 - 获取默认地址接口")
public class AddressBookController {

    @Autowired
    private IAddressBookService iAddressBookService;
    @GetMapping("/defaultAddress")
    @ApiOperation("/获取默认操作地址")
    public AddressBookResDTO getDefaultAddress() {
        return iAddressBookService.getDefaultAddress();
    }

    @PostMapping("")
    @ApiOperation("新增地址簿")
    public void insertAddressBook(@RequestBody AddressBookUpsertReqDTO addressBookUpsertReqDTO) {
        iAddressBookService.insertAddressBook(addressBookUpsertReqDTO);
    }

    @GetMapping("/page")
    @ApiOperation("地址簿列表")
    public PageResult<AddressBookResDTO> findByPage (AddressBookPageQueryReqDTO reqDto) {
        return iAddressBookService.findByPage(reqDto);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID查询地址簿详细信息")
    public AddressBookResDTO getAddressById(@PathVariable("id") Long id) {
        return iAddressBookService.getAddressById(id);
    }
    @PutMapping("/{id}")
    @ApiOperation("根据ID编辑地址簿")
    public void updateAddressById(@RequestBody AddressBookUpsertReqDTO reqDTO,@PathVariable("id") Long id) {
        iAddressBookService.updateAddressById(reqDTO, id);
    }
    @DeleteMapping("/batch")
    @ApiOperation("批量删除地址簿OR单独删除")
    public void deleteAddressByIds(@RequestBody List<Long> ids) {
        iAddressBookService.deleteAddressByIds(ids);
    }
    @PutMapping("/default")
    @ApiOperation("设置默认地址")
    public void updateAddressDefault(Integer flag, Long id) {
        iAddressBookService.updateAddressDefault(flag, id);
    }
}
